package com.gujiangbo.spring;

import org.springframework.util.StopWatch;

import java.util.concurrent.TimeUnit;

/**
 * @Author: gujiangbo.co
 * @Contact: 646832012@qq.com
 * @Date: 2021/12/7 15:34
 * @Version: 1.0
 * @Description: Spring 提供的耗时方法StopWatch
 */
public class StopWatchClient {

    public static void main(String[] args) throws InterruptedException {
        StopWatch watch = new StopWatch("耗时开始");
        watch.start("开始点1");
        TimeUnit.SECONDS.sleep(2);
        watch.stop();
        watch.start("开始点2");
        TimeUnit.SECONDS.sleep(3);
        watch.stop();
        watch.start("开始点3");
        TimeUnit.MILLISECONDS.sleep(1200);
        watch.stop();

        System.out.println(watch.prettyPrint());


    }
}
